<?php get_header(); ?>

<div class="content-area">
    <main class="site-main">
        <div class="tag-header">
            <?php
            the_archive_title('<h1 class="tag-title">', '</h1>');
            the_archive_description('<div class="tag-description">', '</div>');
            ?>
        </div>

        <?php if (have_posts()) : ?>
            <div class="tag-posts">
                <?php while (have_posts()) : the_post(); ?>
                    <article class="tag-post">
                        <?php if (has_post_thumbnail()) : ?>
                            <div class="post-thumbnail">
                                <a href="<?php the_permalink(); ?>">
                                    <?php the_post_thumbnail('medium'); ?>
                                </a>
                            </div>
                        <?php endif; ?>
                        <div class="post-content">
                            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            <div class="post-meta">
                                <span class="post-date"><?php echo get_the_date(); ?></span>
                                <span class="post-author"><?php the_author_posts_link(); ?></span>
                            </div>
                            <div class="post-excerpt">
                                <?php echo wp_trim_words(get_the_excerpt(), 55, '...'); ?>
                            </div>
                            <a href="<?php the_permalink(); ?>" class="read-more"><?php _e('阅读全文', 'my-simple-theme'); ?></a>
                        </div>
                    </article>
                <?php endwhile; ?>
            </div>

            <?php the_posts_pagination(array(
                'prev_text' => __('上一页', 'my-simple-theme'),
                'next_text' => __('下一页', 'my-simple-theme'),
            )); ?>

        <?php else : ?>
            <div class="no-posts">
                <p><?php _e('当前标签下没有文章', 'my-simple-theme'); ?></p>
            </div>
        <?php endif; ?>
    </main>
    
    <?php get_sidebar(); ?>
</div>

<?php get_footer(); ?>
